<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>系统认证</title>
    <link rel="Shortcut Icon" href="/static/Img/PageImg/Canva_small_pageIcon.png" sizes="16*16" type="image/x-icon">
    <script type="text/javascript" src="/static/Js/jQuery-3.5.1.js"></script>
    <script type="text/javascript" src="/static/Js/IsIe.js"></script>
    <link rel="stylesheet" href="/static/Css/CommonStyles.css">
    <script type="text/javascript" src="/static/Js/bootstrap/popper.js"></script>
    <script type="text/javascript" src="/static/Js/bootstrap/bootstrap.bundle.min.js"></script>
    <script type="text/javascript" src="/static/Js/bootstrap/bootstrap.min.js"></script>
    <script type="text/javascript" src="/static/Js/LocalDateUtil.js"></script>
    <script type="text/javascript" src="/static/Js/watermark.js"></script>
    <script type="text/javascript" src="/static/Js/GetUserParam.js"></script>
    <link rel="stylesheet" href="/static/Css/bootstrap.min.css">
    <style>
        .SysAuthDiv{
        width: 13em;
        left: 50%;
        transform: translate(-50%,50%);
        position: absolute;
        }
        .submitBtn{
            position: absolute;
        }
    </style>
</head>
<body>
<div id="header"></div>
<div class="SysAuthDiv">
    <form >
        <div class="form-group ">
            <label for="fullName">真实姓名</label>
            <input type="text" onblur="checkFullName()" class="form-control" id="fullName" aria-describedby="emailHelp">
            <small id="fullNameHelp" class="form-text text-muted">当前阶段的唯一识别标记,请认真填写</small>
        </div>
        <div class="form-group">
            <label for="pram_select_01">归属</label>
            <select class="custom-select" id="pram_select_01">
                <option selected value="Final_Check1">终检1系</option>
                <option value="Final_Check2">终检2系</option>
                <option value="Manage">管理系</option>
                <option value="Sampling">抽查系</option>
            </select>
            <small id="groupHelp" class="form-text text-muted">选择归属后,将由本组超级用户审核</small>
        </div>
        <button type="button" onclick="SysAuthSubmitBtn()" id="submitBtn" class="btn btn-primary submitBtn">提交</button>
    </form>
</div>
<script>

    $.get('/templates/HeadPage.html',function(data){
        $("#header").html(data)
    })
    $.get("/templates/Toasts.html",function (data){
        $("#ToastsPage").html(data)
    })
    let user = GetUserParam();
    __canvasWM({
        content: user.data.uname
    });

    /*"^[\u4E00-\u9FA5]{0,}$"*/
    function checkFullName() {
        let rge = /^[\u4e00-\u9fa5]{1,5}$/
        let fullName = document.getElementById("fullName").value

        if (!rge.test(fullName)){
            document.getElementById("fullNameHelp").innerHTML = "请输入2到4位汉字"
            document.getElementById("fullName").focus()
            document.getElementById("submitBtn").style.visibility = "hidden"
        }else {
            document.getElementById("fullNameHelp").innerHTML = "当前阶段的唯一识别标记,请认真填写"
            document.getElementById("submitBtn").style.visibility = "visible"
        }
    }
    function SysAuthSubmitBtn() {
        $("#message_Div").empty()
        let fullName = document.getElementById("fullName").value
        let groupSelect = document.getElementById("pram_select_01")
        let index = groupSelect.selectedIndex
        let group = groupSelect.options[index].value;
        console.log(group)
        $.post("/user/SysAuthentication",{fullName:fullName,group:group},function (result) {
           if (result.flag) {
                   let message = "刚刚";
                   var html = '<div class="toast" role="alert"  data-delay="5000" aria-live="assertive" aria-atomic="true" >'
                       + '       <div class="toast-header">'
                       + '         <img height="25px" width="25px" src="/static/Img/PageImg/Canva_small.png" class="rounded mr-2" alt="">'
                       + '         <strong class="mr-auto" style="color: green">认证已提交！</strong>'
                       + '          &nbsp;&nbsp;&nbsp;&nbsp;'
                       + '         <small class="text-muted">' + message + '</small>'
                       + '         <button type="button" class="ml-2 mb-1 close" onclick="deleteToast()" data-dismiss="toast" aria-label="Close">'
                       + '           <span aria-hidden="true">&times;</span>'
                       + '         </button>'
                       + '       </div>'
                       + '       <div class="toast-body">'
                       + '          &nbsp;&nbsp;&nbsp;&nbsp;'
                       + "认证已提交,请等待审核！"
                       + '          &nbsp;&nbsp;&nbsp;&nbsp;'
                       + '       </div>'
                       + '     </div>';
                   $("#message_Div").append(html)
                   $('.toast').toast("show")
                   setTimeout(function (){
                       window.location.href = "/index.html"
                   },3000)
               }else {
                   let message = "刚刚";
                   var html = '<div class="toast" role="alert"  data-delay="5000" aria-live="assertive" aria-atomic="true" >'
                       + '       <div class="toast-header">'
                       + '         <img height="25px" width="25px" src="/static/Img/PageImg/Canva_small.png" class="rounded mr-2" alt="">'
                       + '         <strong class="mr-auto" style="color: red">认证提交失败</strong>'
                       + '          &nbsp;&nbsp;&nbsp;&nbsp;'
                       + '         <small class="text-muted">' + message + '</small>'
                       + '         <button type="button" class="ml-2 mb-1 close" onclick="deleteToast()" data-dismiss="toast" aria-label="Close">'
                       + '           <span aria-hidden="true">&times;</span>'
                       + '         </button>'
                       + '       </div>'
                       + '       <div class="toast-body">'
                       + '          &nbsp;&nbsp;&nbsp;&nbsp;'
                       + "重复认证,请耐心等待审核！"
                       + '          &nbsp;&nbsp;&nbsp;&nbsp;'
                       + '       </div>'
                       + '     </div>';
                   $("#message_Div").append(html)
                   $('.toast').toast("show")


               }

        })
    }
</script>
</body>
</html>